package com.jomoo.remark.dao.impl;


import javax.annotation.Resource;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.jomoo.remark.dao.RemarkDao;

/**
 * 
* @ClassName: RemarkDaoImpl 
* @Description:  
* @author sddm.haosc
* @date 2017年12月12日 上午10:49:12 
*
 */
@Repository
@Transactional(rollbackFor = Exception.class)
public class RemarkDaoImpl implements RemarkDao
{

	@Resource(name = "sessionFactory")
	private SessionFactory sessionFactory;
	
	/**
	 * 持久化任意对象
	 */
	@Override
	public Integer saveAllObj(Object obj) throws Exception
	{
		Session session = sessionFactory.openSession();
		
		Integer iId = null;

		try
		{
			iId = (Integer) session.save(obj);
		}
		catch (Exception e)
		{
			e.printStackTrace();
			throw e;
		}
		finally
		{
			if (null != session)
			{
				session.close();
			}
			if (null != sessionFactory)
			{
				sessionFactory.close();
			}
		}
		return iId;
	}
}